package com.pbking.facebook.delegates.fbml
{
	import com.pbking.facebook.Facebook;
	import com.pbking.facebook.FacebookSessionType;
	import com.pbking.facebook.delegates.FacebookDelegate;
	
	/**
	 * delegate for calling fbml.setRefHandle.  
	 * does not work for desktop application.    
	 * 
	 * @author sol wu
	 */
	public class SetRefHandleDelegate extends FacebookDelegate
	{			
		/**
		 * @param handle - The handle to associate with the given FBML
		 * @param fbml - The FBML to associate with the given handle.
		 */
		public function SetRefHandleDelegate(facebook:Facebook, handle:String, fbml:String)
		{
			super(facebook);
			
			// setRefHandle() is disabled for desktop app according to wiki				
			if (FacebookSessionType.WEB == facebook.sessionType) {
				fbCall.useSession = false;
			}
			
			if (handle != "") { fbCall.setRequestArgument("handle", handle); }
			if (fbml != "") { fbCall.setRequestArgument("fbml", fbml); }
			fbCall.post("facebook.fbml.setRefHandle");
		}

	}
}